// ConfirmWithLoading.js
import { h } from 'vue'

export default {
  props: ['onConfirm'],
  setup(props) {
    const loading = ref(false)

    return () => h('el-button', {
      loading: loading.value,
      async onClick() {
        try {
          loading.value = true
          await props.onConfirm()
          ElMessage.closeAll()
        } finally {
          loading.value = false
        }
      }
    }, '确认')
  }
}
